package session

import (
	"OnlineRetailers/models"
	"OnlineRetailers/models/Admin"
)

func NewSession(session *Admin.Session, sessionJson []byte) (err error) {

	conn := models.Pool.Get()

	defer func() {
		err = conn.Close()
		if err != nil {
			return
		}
	}()

	_, err = conn.Do("SET", session.SessionId, sessionJson)
	if err != nil {
		return
	}
	err = UpdateSession(session.SessionId)

	return

}
